package com.nbsaas.boot.product.rest.convert;

import com.nbsaas.boot.product.data.entity.ProductImage;
import com.nbsaas.boot.product.api.domain.response.ProductImageResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;
/**
* 商品图片-实体对象转化成响应对象
*/

public class ProductImageResponseConvert  implements Converter<ProductImageResponse,ProductImage> {

    @Override
    public ProductImageResponse convert(ProductImage source) {
        ProductImageResponse  result = new  ProductImageResponse();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getProduct()!=null){
                        result.setProduct(source.getProduct().getId());
                    }

                    try {
                        if(source.getProduct()!=null){
                            result.setProductName(source.getProduct().getName());
                        }
                    } catch (Exception ignored) { }

        return result;
    }

}

